/**
 * 视频服务
 */
import {request} from '@umijs/max';
import VideoQueryRequest = VideoType.VideoQueryRequest;




/**
 * 添加视频
 *
 * @param data
 */
export async function addVideo(data: VideoType.VideoAddRequest) {
    return request<BaseResponse<boolean>>(`smallVideos/add`, {
        method: 'POST',
        data: data,
        headers: {
            'Content-Type': 'application/json',
        }
    })
}

/**
 * 删除视频
 *
 * @param id
 */
export async function deleteVideo(id: number) {
    return request<BaseResponse<boolean>>(`smallVideos/delete`, {
        method: 'POST',
        params: {id: id},
        headers: {
            'Content-Type': 'application/json',
        }
    })
}

/**
 * 更新视频信息
 * @param data
 */
export async function updateVideo(data: VideoType.VideoUpdateRequest) {
    return request<BaseResponse<boolean>>(`smallVideos/update`, {
        method: 'POST',
        data: data,
        headers: {
            'Content-Type': 'application/json',
        }
    })
}


/**
 * 根据id获得视频信息
 *
 * @param id
 */
export async function getVideoById(id: number) {
    return request<BaseResponse<VideoType.Video>>(`smallVideos/get`, {
        method: 'GET',
        params: {id: id},
        headers: {
            'Content-Type': 'application/json',
        }
    })
}

/**
 * 获得小视屏列表
 *
 * @param params
 */
export async function queryVideoList(params: VideoQueryRequest) {
    return request<BaseResponse<PageInfo<VideoType.Video>>>('smallVideos/list/page', {
        method: 'GET',
        params: {...params},
        headers: {
            'Content-Type': 'application/json',
        }
    });
}

/**
 * 获得用户的视频列表
 *
 * @param userId
 * @param params
 */
export async function queryVideoListByUserId(userId:number, params: PageRequest){
    return request<BaseResponse<PageInfo<VideoType.Video>>>('smallVideos/list/page/'+userId, {
        method: 'GET',
        params: params,
        headers: {
            'Content-Type': 'application/json',
        }
    });
}


/**
 * 查询所有关注我的所有用户
 */
export async function findFocus() {
    return request<BaseResponse<UserType.UserVO[]>>('comment/findFocus', {
        method: 'GET',
    });
}


/**
 * 取消关注作者
 * @param id
 */
export async function useUnFocus(id: number) {
    return request<BaseResponse<boolean>>('comment/' + id + '/useUnFocus', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        }
    });
}

/**
 * 关注作者
 *
 * @param id
 */
export async function useFocus(id: number) {
    return request<BaseResponse<boolean>>('comment/' + id + '/useFocus', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        }
    });
}


/**
 * 视屏点赞
 *
 * @param id
 * @constructor
 */
export async function like(id: number) {
    return request<BaseResponse<number>>('comment/' + id + '/like', {
        method: 'GET',
    });
}

/**
 * 取消视屏点赞
 *
 * @param id
 * @constructor
 */
export async function unLike(id: number) {
    return request<BaseResponse<number>>('comment/' + id + '/unlike', {
        method: 'GET',
    });
}